package com.stud.common.enums;

import com.stud.common.exception.ServiceException;

/**
 * @author Stud
 * @title X轴类型枚举
 * @desription XXXXX
 * @data 2022-11-16 17:39
 */
public enum WorkflowStatusEnum {

    FAIL(-1, "驳回"),

    WAITING(0, "待审核"),

    APPROVING(1, "审核中"),

    PASS(2, "审核通过"),
    ;

    private final int code;
    private final String name;

    WorkflowStatusEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public WorkflowStatusEnum code2Enum(int code) {
        switch (code) {
            case -1:
                return FAIL;
            case 0:
                return WAITING;
            case 1:
                return APPROVING;
            case 2:
                return PASS;
            default:
                throw new ServiceException("状态码异常");
        }
    }

}
